package com.example.controller;

import com.example.pojo.entity.JobSeeker;
import com.example.service.NavService;
import com.example.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 导航栏
 * @author ..
 * @Date 2023/10/11 22:59
 */
@RestController
@RequestMapping("navUser")
public class NavController {
    @Autowired
    private NavService navService;
    @GetMapping("{userId}")
    public Result nav(@PathVariable("userId") Integer userId){
        if (userId!=null){
            JobSeeker jobSeeker = navService.getJSName(userId);
            if (jobSeeker!=null){
                System.out.println(jobSeeker);
                JobSeeker jobSeeker1 = new JobSeeker();
                jobSeeker1.setId(userId);
                jobSeeker1.setJsName(jobSeeker.getJsName());
                jobSeeker1.setAvatar(jobSeeker.getAvatar());
                System.out.println("=头像=");
                System.out.println(jobSeeker);
                return new Result(200,"查询成功",jobSeeker1);
            }
            return new Result(501,"未查询到用户");
        }
        return new Result(502,"用户id错误");
    }
}
